import java.util.Scanner;

class UserNameException extends Exception{
    public UserNameException(String message) {
        super(message);
    }
}
class PassWordException extends Exception{
    public PassWordException(String message) {
        super(message);
    }
}

public class TestDemo {
    public static void login(String userName,String passWord)throws UserNameException,PassWordException{
        if(!userName.equals("wjh")){
            throw new UserNameException("用户名错误！");
        }
        if(!  passWord.equals("123456")){
            throw new UserNameException("密码错误！");
        }
        System.out.println("登陆成功！");
    }
    public static void main(String[] args) {
        System.out.println("请输入用户名和密码！");
        Scanner scanner=new Scanner(System.in);
        System.out.print("UserName: ");
        String user=scanner.nextLine();
        System.out.print("PassWord: ");
        String word=scanner.nextLine();
        try {
            login(user,word);
        } catch (UserNameException e) {
            e.printStackTrace();
        } catch (PassWordException e) {
            e.printStackTrace();
        }
        finally {
            scanner.close();
        }
    }
}
